package com.s3.khospitalds.controller;

import com.s3.khospitalds.common.R;
import com.s3.khospitalds.entity.Userlogin;
import com.s3.khospitalds.service.UserloginService;
import com.s3.khospitalds.service.impl.UserloginServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: xw
 * @CreateTime: 2025/2/17
 * @Description: 登录用户
 * @Version: 1.0
 */
@RestController
@CrossOrigin(origins = "*")
public class UserloginController {
    @Autowired
    private UserloginServiceImpl userloginService;
    @RequestMapping("/userlogin")
    public R userlogin(Userlogin userlogin) {//登录的方法
        System.out.println(userlogin.getName()+"=="+userlogin.getPassword());
         userlogin = userloginService.userlogin(userlogin.getName(), userlogin.getPassword());
        if (userlogin==null) {
            return new R().setCode(502).setMsg("登录出错");
        }else {
            return new R().addData("userlogin",userlogin);
        }

    }
}
